using System.Text;
using Oracle.ManagedDataAccess.Client;

namespace OracleInternal.BinXml
{
	internal class ObxmlTokenManagerContext
	{
		private string[] m_TokenMgrStringIds;

		private object[] m_TokenMgrObjectIds;

		private string m_PartitionId = string.Empty;

		internal bool IsValid
		{
			get
			{
				if (m_TokenMgrObjectIds != null)
				{
					return m_TokenMgrStringIds != null;
				}
				return false;
			}
		}

		internal string PartitionId
		{
			get
			{
				if (!string.IsNullOrEmpty(m_PartitionId))
				{
					return m_PartitionId;
				}
				StringBuilder stringBuilder = new StringBuilder(100);
				if (m_TokenMgrStringIds != null)
				{
					string[] tokenMgrStringIds = m_TokenMgrStringIds;
					foreach (string value in tokenMgrStringIds)
					{
						if (!string.IsNullOrEmpty(value))
						{
							stringBuilder.Append(value);
						}
					}
				}
				if (m_TokenMgrObjectIds != null)
				{
					object[] tokenMgrObjectIds = m_TokenMgrObjectIds;
					foreach (object obj in tokenMgrObjectIds)
					{
						if (obj != null)
						{
							stringBuilder.Append(obj.ToString());
						}
					}
				}
				return m_PartitionId = stringBuilder.ToString();
			}
		}

		internal ObxmlTokenManagerContext()
		{
		}

		internal static ObxmlTokenManagerContext CreateDefaultTokenManagerContext(OracleConnection connection)
		{
			return new ObxmlTokenManagerContext(new string[2]
			{
				"Token Set GUID",
				connection.ConnectionString
			}, new object[2]
			{
				1,
				2
			});
		}

		internal ObxmlTokenManagerContext(string[] tokenMgrStringIds, object[] tokenMgrObjectIds)
		{
			m_TokenMgrStringIds = tokenMgrStringIds;
			m_TokenMgrObjectIds = tokenMgrObjectIds;
		}
	}
}
